function raf() {
    let startTime = 0;
    let lastTime = 0;
    let count = 0;

    function step(times: number) {
        if(startTime == 0){
            startTime = times;
        }
        count = count + 1;
        let allTime = times - startTime;
        let intervalTime = times - lastTime;
        
        lastTime = times;
        // console.log("step", times);
        // console.log("count",times,allTime,intervalTime);
        update(intervalTime);
        render();

        requestAnimationFrame(step);
    }

    requestAnimationFrame(step);
    // setInterval(step,1/60)

    let posX = 0;
    let speedX = 10;

    function update(
        intervalTime:number
    ){
        let t = intervalTime / 1000;
        posX = posX + speedX * t
        console.log("posX",posX)
    }

    function render(){
        console.log("render")
    }
}


export {
    raf
}
